<?php
require_once 'pages/TMSAdminPage.inc';
require_once 'models/TMSTypesModel.inc';

class TMSGlossaryLink {
	private $_type_;
	private $_page_;
	
	public function __construct(TMSTypeItem $type, TMSAdminPage $page){
		$this->_type_ = $type;
		$this->_page_ = $page;
	}
	
	public function Link(){
		return $this->_page_->GlossaryUrl($this->_type_->ClassName);
	}
	
	public function Title(){
		return $this->_type_->Name;
	}
}

class TMSGlossaryLinkIterator extends TIteratorAdapter {
	private $_page_;
	
	public function __construct(IIterator $base, TMSAdminPage $page){
		parent::__construct($base);
		$this->_page_ = $page;
	}
	
	public function Item(){
		return new TMSGlossaryLink(parent::Item(), $this->_page_);
	}
}


class TMSAdminGlossariesPage extends TMSAdminPage {
	public function Links(){
		return new TMSGlossaryLinkIterator($this->Model->GetList(new TListOptions(array(new TFilterOption('BaseClass', TConditionType::C_EQUAL, TMSType::BASE_NONE)))),$this);
	}
	
	public function GlossaryUrl($classname){
		return $this->Service()->GlossaryUrl($classname,'list');
	}
}